package cn.dust.design.pattern.structural.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: dust
 * @Date: 2019/11/26 21:39
 */
public class EmployeeFactory {

    private static final Map<String ,Employee> EMPLOYEE_MAP=new HashMap<String, Employee>();


    public static Employee getManager(String department){
        Manager manager= (Manager) EMPLOYEE_MAP.get(department);
        if(manager==null){
            manager=new Manager(department);
            System.out.print("创建部门经理"+department);
            String reportContent=department+"经理正在作报告......";
            manager.setReportContent(reportContent);
            System.out.print("创建报告"+reportContent);
            EMPLOYEE_MAP.put(department,manager);
        }
        return manager;
    }


}
